
class ProductError:
    """商品相关异常"""
    def __init__(self, code=2000):
        self.code = code
        if code == 2000:
            message = '商品不存在'
        elif code == 2001:
            message = '商品已下架'
        elif code == 2002:
            message = '商品已售罄'
        else:
            message = '系统异常'
        super().__init__(message)

class LoginError(Exception):
    """登录失败时根据用户名和密码提示"""
    def __init__(self, code=1000):
        self.code = code
        if code == 1000:
            message = '用户名不正确，请输入正确用户名'
        elif code == 1001:
            message = '密码不正确，请输入正确密码'
        elif code == 1002:
            message = '用户名已存在!'
        elif code == 1003:
            message = '邮箱格式错误，请重新输入!'
        elif code == 1004:
            message = '手机号格式错误，请重新输入!'
        else:
            message = '系统异常'
        super().__init__(message)
